package com.ttc.mBackup.BackupAgent;

import java.util.ArrayList;

import com.ttc.mBackup.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListLocaltion extends BaseAdapter {

	private final ArrayList<listviewlocal> lv;
	
	public ListLocaltion(ArrayList<listviewlocal> convertView)
	{
		this.lv=convertView;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lv.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return lv.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewGroup view = getViewGroup(convertView,parent);
		listviewlocal lvl = lv.get(position);
		TextView label = (TextView) view.findViewById(R.id.local_label);
		TextView deltail = (TextView) view.findViewById(R.id.local_detail);
		ImageView ig=  (ImageView) view.findViewById(R.id.image_local);
		label.setText(lvl.name);
		deltail.setText(lvl.detail);
		ig.setImageResource(lvl.image);
		return view;
	}
	
	private ViewGroup getViewGroup(View convertView,ViewGroup parent)
	{
	if(convertView instanceof ViewGroup)
	{
		return (ViewGroup)convertView;
	}
	Context context = parent.getContext();
	LayoutInflater inflater = LayoutInflater.from(context);
	ViewGroup item = (ViewGroup) inflater.inflate(R.layout.listlocalitem , null);
	return item;
	}

}
